<#assign str=chart.YColumn?split(",")>
<#assign YColumn=str[0]>
<#assign yname=chart.getY(YColumn)>
<#assign colors=chart.getColorList(str?size+5)>
<script type="text/javascript">
function drawdbar${chart.id}(){
	var data_${chart.id} = ${resultDatas};
	document.getElementById("div_title_${chart.id}").innerHTML="";
	if('${chart.type}'=='bar'){
	document.getElementById("div_title_${chart.id}").innerHTML="<center style=\"font-size:16px;font-weight:bold;\">${chart.title?default("")}</center>"
														+"<div id=\"bar-${chart.id}\" style=\"width:${chart.width};height:${chart.height};border:0px solid #A4BED4;\"></div>";
	var barChart${chart.id} =  new dhtmlXChart({
		view:"${chart.type}", //当前用的为bar
		container:"bar-${chart.id}",
	    value:"#${YColumn?upper_case}#",
	    label:"#${YColumn?upper_case}#",
		width:${chart.parameterMap.bar_width?default("30")},
		padding :{
			top:15,
			bottom:${chart.parameterMap.padding_bottom?default("50")},
			left:${chart.parameterMap.padding_left?default("50")}
		},
		color:"${colors[0]}",
		<#if str?size gt 1>
		legend:{
			layout:"x",
			width: 75,
			align:"center",
			valign:top,
			marker:{
				type:"round",
				width:10,
				height:10
			},
			values:[
			<#list str as Y>
				<#if Y_index!=0>,</#if>{text:"${chart.getY(Y).display}",color:"${colors[Y_index]}"}
			</#list>
			] 
		},	
		</#if>
		tooltip:{
			template:"#${chart.XColumn?upper_case}#"
		},
		xAxis:{
			template:function(obj, common, data){
               var temp=obj.${chart.XColumn?upper_case};
			var result="";
			var rowLength=${chart.parameterMap.rowlength?default("6")};
			if(temp.length>rowLength){
				for(var i=0;i<temp.length/rowLength;i++){
					result+=temp.substr(i*rowLength,rowLength)+"<br>";
				}
			}else{
				result+=temp;
			}
			return result},
			color :"${chart.parameterMap.axisColor?default("#C6C6C6")}",
			title:"<B>${chart.x.display}"
			//lines: true	
		},
		yAxis:{
			<#if chart.parameterMap.y_step??>
			start:${chart.parameterMap.y_start?default("0")},
			<#if chart.parameterMap.y_end??>
			end:${chart.parameterMap.y_end},
			<#else>
			end:${chart.parameterMap.y_step?number*5},
			</#if>
			step:${chart.parameterMap.y_step},
			</#if>
			//lines: true	
			color :"${chart.parameterMap.axisColor?default("#C6C6C6")}",
			title:"<B><#if str?size lt 1>${yname.display}</#if>"
			
		},		
		//origin:0,  
		gradient:true, 
		border:false
	});
	
	<#list str as Y>
		<#if Y_index!=0>
			barChart${chart.id}.addSeries({
				value:"#${Y?upper_case}#",
				color:"${colors[Y_index]}",
				label:"#${Y?upper_case}#"
			})
		</#if>
	</#list>
	
	barChart${chart.id}.parse(data_${chart.id},"json");
	}
	if('${chart.type}'=='barH'){
		document.getElementById("div_title_${chart.id}").innerHTML="<center style=\"font-size:16px;font-weight:bold;\">${chart.title?default("")}</center>"
														+"<div id=\"barH-${chart.id}\" style=\"width:${chart.width};height:${chart.height};border:0px solid #A4BED4;\"></div>";
	var barH${chart.id} =  new dhtmlXChart({
		view:"barH",
		container:"barH-${chart.id}",
	    value:"#${YColumn?upper_case}#",
		width:${chart.parameterMap.bar_width?default("30")},
		padding:{
    	  left:${chart.parameterMap.padding_left?default("100")}
	    },
		label: "#${YColumn?upper_case}#",
		color:"${colors[0]}",
		gradient:true,
		//gradient:function(gradient){
		//		gradient.addColorStop(1.0,"#FF0000");
		//		gradient.addColorStop(0.3,"#FFFF00");
		//		gradient.addColorStop(0.0,"#00FF22");
		//},
		tooltip:{
			template:"#${chart.XColumn?upper_case}#"
		},
		xAxis:{
			<#if chart.parameterMap.x_step??>
			start:${chart.parameterMap.x_start?default("0")},
			<#if chart.parameterMap.x_end??>
			end:${chart.parameterMap.x_end},
			<#else>
			end:${chart.parameterMap.x_step?number*5},
			</#if>
			step:${chart.parameterMap.x_step},
			</#if>
			title:"<B>${yname.display}",
			lines: true
		},
		<#if str?size gt 1>
		legend:{
			layout:"x",
			width: 75,
			align:"center",
			valign:top,
			values:[
			<#list str as Y>
				<#if Y_index!=0>,</#if>{text:"${chart.getY(Y).display}",color:"${colors[Y_index]}"}
			</#list>
			]
		},
		</#if>
		yAxis:{
			title:"<B>${chart.x.display}",
			template:"#${chart.XColumn?upper_case}#"
		}
		
	})
		<#list str as Y>
		<#if Y_index!=0>
			barH${chart.id}.addSeries({
				value:"#${Y?upper_case}#",
				color:"${colors[Y_index]}",
				label:"#${Y?upper_case}#"
			})
		</#if>
	</#list>
	barH${chart.id}.parse(data_${chart.id},"json");
	}
}
	if(${resultDatas}.length>0){
		if (window.addEventListener) {   
			//window.addEventListener('DOMContentLoaded', drawdbar${chart.id}, false);  
			window.addEventListener('load', drawdbar${chart.id}, false);  //firefox
		} else if (window.attachEvent)  {
		  window.attachEvent('onload',drawdbar${chart.id}); //IE
		}
	}else{
		document.getElementById("div_title_${chart.id}").removeNode(true);
		var node=document.getElementById("information");
		if(node){
			node.innerHTML="<span style='color:red;font-size:14;'>提示:查询无数据!</span>";
		}
	}
</script>